package com.wedo.mall.activity.main;

import android.os.Bundle;
import android.widget.LinearLayout;

import com.e.library.activity.EActivity;
import com.e.library.widget.ETitleBar;
import com.wedo.mall.R;
import com.wedo.mall.util.WUrl;
import com.wedo.mall.widget.EWebView;

import butterknife.BindView;

/**
 * Created by e on 2017/7/6.
 */

public class WebActivity extends EActivity {

    public static final String EXTRA_TITLE = "title";
    public static final String EXTRA_URL = "url";

    public static void toWeb(EActivity activity,String url){
        toWeb(activity,url,"");
    }

    public static void toWeb(EActivity activity,String url,String title){
        Bundle bundle = new Bundle();
        bundle.putString(EXTRA_URL,url);
        bundle.putString(EXTRA_TITLE,title);
        activity.toActivity(WebActivity.class,bundle);
    }

    @BindView(R.id.ll_web) LinearLayout ll_web;
    @BindView(R.id.title_bar) ETitleBar title_bar;
    private EWebView mWebView;

    @Override
    protected int layout() {
        return R.layout.activity_web;
    }

    @Override
    protected void onActivityCreated(Bundle state) {
        mWebView = new EWebView(ll_web);
        String url = WUrl.url(getIntent().getStringExtra(EXTRA_URL));
        String title = getIntent().getStringExtra(EXTRA_TITLE);
        title_bar.setTitle(title);
        mWebView.url(url);
    }

    @Override
    protected void onPause() {
        super.onPause();
        isCorE();
    }

    @Override
    protected void onDestroy() {
        mWebView.onDestroy();
        super.onDestroy();
    }
}
